Skip to content

canonicalize crate name before checking if it's reserved #591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

sgrif
Copy link
Contributor

@sgrif sgrif commented Mar 5, 2017

Currently reserved crate names come from a text file in the source.
There are only two entries which consider canonicalization (e.g. the
list contains compiler-rt and compiler_rt). The fact that the name
is not canonicalized allows crates like https://crates.io/crates/std to
be uploaded. While this definitely isn't a vulnerability, since the
registry does not canonicalize the name, we should still disallow
crates to be uploaded which appear at the same path as a reserved name,
and would prevent a crate with a reserved name from being uploaded
later.

I've moved the actual data out of the text file, and into the database,
so we can have a constraint which verifies this at the closest possible
location. (We can't use an actual check constraint, as that disallows
subselects).

The crate referenced above should be manually deleted.

Currently reserved crate names come from a text file in the source.
There are only two entries which consider canonicalization (e.g. the
list contains `compiler-rt` and `compiler_rt`). The fact that the name
is not canonicalized allows crates like https://crates.io/crates/std to
be uploaded. While this definitely isn't a vulnerability, since the
registry does *not* canonicalize the name, we should still disallow
crates to be uploaded which appear at the same path as a reserved name,
and would prevent a crate with a reserved name from being uploaded
later.

I've moved the actual data out of the text file, and into the database,
so we can have a constraint which verifies this at the closest possible
location. (We can't use an actual check constraint, as that disallows
subselects).

The crate referenced above should be manually deleted.
@Eh2406
Copy link
Contributor

Eh2406 commented Mar 6, 2017

This also removes the code that was scanning the list linearly. +1

@alexcrichton
Copy link
Member

FWIW this list gets updates from time to time, so having it relatively easy to modify would be nice. This'd just require a migration per modification, right?

@sgrif
Copy link
Contributor Author

sgrif commented Mar 6, 2017

Yes. There's no way to provide a database level constraint that doesn't require a migration per modification. I could write a binary that generates the migration automatically if you'd like (after #589)

@carols10cents
Copy link
Member

Seems fine 👍

@carols10cents carols10cents merged commit 3932e8d into rust-lang:master Mar 7, 2017
@sgrif sgrif deleted the sg-check-canon-crate-name-on-upload branch March 7, 2017 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants